package behavioral.strategy;

public class StrategyPattern {
    public static void main(String[] args) {
        // Create a new ImageStorage object with a PNG compressor
        ImageStorage imageStorage = new ImageStorage(new PngCompressor());
        // Store an image using the PNG compressor
        imageStorage.store("image.png");

        // Create a new ImageStorage object with a JPEG compressor
        imageStorage = new ImageStorage(new JpegCompressor());
        // Store an image using the JPEG compressor
        imageStorage.store("image.jpg");

        // 也可以直接传入一个新的压缩器
        imageStorage.store("image.jpg", new PngCompressor());
    }
}
